class Solution(object):
    def dietPlanPerformance(self, calories, k, lower, upper):
        """
        :type calories: List[int]
        :type k: int
        :type lower: int
        :type upper: int
        :rtype: int
        """
        n = len(calories)
        total = sum(calories[: k])
        score = 0
        if total > upper:
            score += 1
        if total < lower:
            score -= 1
        for i in range(n - k):
            total = total + calories[i + k] - calories[i]
            if total > upper:
                score += 1
            if total < lower:
                score -= 1
        return score


data = Solution()
calories = [1, 2, 3, 4, 5]
k = 1
lower = 3
upper = 3
print(data.dietPlanPerformance(calories, k, lower, upper))
